wait for API call or subscription to finish